﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Framework_Tool
{
    /// <summary>
    /// Interaction logic for StaffAdd.xaml
    /// </summary>
    public partial class StaffAdd : Page
    {
        private MainWindow main;

        public StaffAdd(MainWindow main)
        {
            InitializeComponent();
            this.main = main;
        }

        private void stfAdd_Click(object sender, RoutedEventArgs e)
        {
            Database.CreateStaff(this);
        }

        private void mainContent_Loaded_1(object sender, RoutedEventArgs e)
        {
            string id = Database.NextStaffID();
            stfIDAddTxt.Text = id;
            
            viewStaff.FontWeight = FontWeights.Normal;
            addStaff.FontWeight = FontWeights.ExtraBold;
            updateStaff.FontWeight = FontWeights.Normal;
            deleteStaff.FontWeight = FontWeights.Normal;
            searchStaff.FontWeight = FontWeights.Normal;
        }

        public void resetStfAdd_Click(object sender, RoutedEventArgs e)
        {
            stfFNameTxt.Text = null;
            stfSurnameTxt.Text = null;
            stfALine1Txt.Text = null;
            stfALine2Txt.Text = null;
            stfCityTxt.Text = null;
            stfCountyTxt.Text = null;
            stfPostcodeTxt.Text = null;
            stfJobTitleTxt.Text = null;
            stfTelNoTxt.Text = null;
            stfEmailTxt.Text = null;
            stfPasswordAddTxt.Password = null ;
            stfPassword1AddTxt.Password = null;
            matchStfPasswordLbl.Visibility = Visibility.Hidden;
            validStfPasswordLbl.Visibility = Visibility.Hidden;
            stfEmailValidationLbl.Visibility = Visibility.Hidden;
        }

        public void updateStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffUpdate stfUpdateWindow = new StaffUpdate();
            stfUpdateWindow.Content = null;
            mainContent.Children.Add(stfUpdateWindow.mainContent);
        }

        private void deleteStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffDelete stfDeleteWindow = new StaffDelete();
            stfDeleteWindow.Content = null;
            mainContent.Children.Add(stfDeleteWindow.mainContent);
        }

        private void searchStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffSearch stfSearchWindow = new StaffSearch();
            stfSearchWindow.Content = null;
            mainContent.Children.Add(stfSearchWindow.mainContent);
        }

        private void viewStaff_Click(object sender, RoutedEventArgs e)
        {
            StaffView stfViewWindow = new StaffView();
            stfViewWindow.Content = null;
            mainContent.Children.Add(stfViewWindow.mainContent);
        }

        private void stfEmailTxt_LostFocus_2(object sender, RoutedEventArgs e)
        {
            Database.IsValidStfEmail_StaffAdd(this);
        }

        private void stfPasswordAddTxt_LostFocus_2(object sender, RoutedEventArgs e)
        {
            Database.ValidatePassword_StaffAdd(this);
        }

        private void stfPassword1AddTxt_LostFocus_2(object sender, RoutedEventArgs e)
        {
            Database.ComparePasswords_staffAdd(this);
        }

    }
}
